﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        private int Connection_Type = 0; //{0-NoConnection,1-Guset,2-User,3-Moderator,4-Admin}
        int pushed_now;
        RegFrm RegisterForm;
        Form3 LoginForm;
        Form5 EditForm;
        Form6 AddThreadForm;
        Form7 AddSubjectForm;

        Boolean EditOpen = false;
        string EditText;
        Boolean DeleteThread = false;
        Boolean DeleteSubject = false;

        int counter = 0;


        //*****************
        //page place ment info
        Boolean Is_Subject_screen = false; //we are on the main screen
        Boolean Is_Thread_screeen = false; //we are on the thread screen
        Boolean Is_Post_Screen = false;

        //*****************
        public Form2()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
       
        private void Activate_Guest_Mode()
        {
            this.label7.Text = "Connected as a Guest";
            this.button22.Show();
            this.button23.Show();
            this.button24.Hide();
            this.button25.Hide();
            this.button26.Hide();
            this.button29.Hide();
            this.button28.Hide();
            this.button30.Hide();
            this.button31.Hide();
            this.button32.Hide();
        }

        private void Activate_Connected_Mode()
        {
            this.label7.Text = "Connected as a Registered User";
            this.button22.Hide();
            this.button23.Hide();
            this.button25.Hide();
            this.button26.Hide();
            this.button31.Show();
            this.button32.Show();
        }

        private void Activate_Moderator_Mode()
        {
            this.label7.Text = "Connected as a Moderator";
            this.button24.Show();
            this.button29.Show();
            this.button28.Show();
            this.button30.Show();

        }

        private void Activate_Admin_Mode()
        {
            this.label7.Text = "Connected as an Admin";
            this.button24.Show();
            this.button25.Show();
            this.button26.Show();
            this.button29.Show();
            this.button28.Show();
            this.button30.Show();
        }

        private void Show_Subject_Page()
        {//prepare the page for show
            this.label5.Text = "Forum Subjects";
            this.Showpanel();
            this.button31.Hide();
            this.button32.Hide();
            this.Is_Subject_screen = true;
            this.Is_Thread_screeen = false;
        }

        private void Show_Thread_Page()
        {//prepare the page for show
            this.label5.Text = "Forum Threads";
            this.Showpanel();
            this.button31.Show();
            this.button32.Show();
            this.Is_Subject_screen = false;
            this.Is_Thread_screeen = true;
        }

        private void Show_post_Page()
        {//prepare the page for show
            this.hidepanel();
            this.button31.Hide();
            this.button32.Hide();
            this.Is_Subject_screen = false;
            this.Is_Thread_screeen = false;

        }

        public void hidepanel()
        {
            panel1.Hide();
        }

        public void Showpanel()
        {
            panel1.Show();
        }


        public void PutPosts()
        {
            //this method will arange the posts in the right place/the main subject too
            //it will also rest all the needed data
        }

        public void Putthreads()
        {
            //this method will arange the posts in the right place/the main subject too
            //it will also rest all the needed data
        }



        private void Show_Those_threadsOrSubjects(int Number)
        {
            for (int i = 1; i < 10; i++)
            {
                if (i <= Number)
                    ShowThisThread(i);

                if (i > Number)
                    HideThisThread(i);
            }
        }

        private void Show_Those_Posts(int Number)
        {
            for (int i = 1; i < 7; i++)
            {
                if (i <= Number)
                    ShowThisPosts(i);

                if (i > Number)
                    HideThisPosts(i);
            }
        }


       // private void 



//*************************************************************************
//*************************************************************************

        private void Form2_Load(object sender, EventArgs e)
        {
            //Activate_Guest_Mode();
            Activate_Connected_Mode();
            this.panel1.Hide();
            //label1.Text = "fuck you!";
            //button1.Text = "yes i agree with you";
            //button2.Text = "yes i liked this";
            //button3.Hide();
            //label3.Hide();
        }

       
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            //panel1.Hide();
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

      
        private void button22_Click(object sender, EventArgs e)
        {//register button
            RegisterForm = new RegFrm();
            RegisterForm.UpdateForm(this);
            this.Hide();
            RegisterForm.Show();
        }

        private void button24_Click(object sender, EventArgs e)
        {//This is Disconnect button 

            //here we send a disconnect message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
            Activate_Guest_Mode();
        }


       

        private void label4_Click(object sender, EventArgs e)
        {


        }

        private void button28_Click(object sender, EventArgs e)
        {

        }

        private void button29_Click(object sender, EventArgs e)
        {

        }

      



//*****************************************************************
        //**********************************************************
        private void ShowThisThread(int i)
        {
            if (i == 1)
            {
                this.button10.Show();
            }

            if (i == 2)
            {
                this.button11.Show();
            }

            if (i == 3)
            {
                this.button12.Show();
            }

            if (i == 4)
            {
                this.button14.Show();
            }

            if (i == 5)
            {
                this.button15.Show();
            }

            if (i == 6)
            {
                this.button16.Show();
            }
            if (i == 7)
            {
                this.button17.Show();
            }

            if (i == 8)
            {
                this.button18.Show();
            }

            if (i == 9)
            {
                this.button19.Show();
            }

        }

        private void HideThisThread(int i)
        {
            if (i == 1)
            {
                this.button10.Hide();
            }

            if (i == 2)
            {
                this.button11.Hide();
            }

            if (i == 3)
            {
                this.button12.Hide();
            }

            if (i == 4)
            {
                this.button14.Hide();
            }

            if (i == 5)
            {
                this.button15.Hide();
            }

            if (i == 6)
            {
                this.button16.Hide();
            }
            if (i == 7)
            {
                this.button17.Hide();
            }

            if (i == 8)
            {
                this.button18.Hide();
            }

            if (i == 9)
            {
                this.button19.Hide();
            }

        }


          private void ShowThisPosts(int i)
          {

              if (i == 1)
              {
                  this.button3.Show();
              }

              if (i == 2)
              {
                  this.button4.Show();
              }

              if (i == 3)
              {
                  this.button5.Show();
              }

              if (i == 4)
              {
                  this.button6.Show();
              }

              if (i == 5)
              {
                  this.button7.Show();
              }

              if (i == 6)
              {
                  this.button8.Show();
              }


          }

          private void HideThisPosts(int i)
          {
              if (i == 1)
              {
                  this.button3.Hide();
              }

              if (i == 2)
              {
                  this.button4.Hide();
              }

              if (i == 3)
              {
                  this.button5.Hide();
              }

              if (i == 4)
              {
                  this.button6.Hide();
              }

              if (i == 5)
              {
                  this.button7.Hide();
              }

              if (i == 6)
              {
                  this.button8.Hide();
              }
          }

          private void EnterTextToSubjectOrThread(string text, int ThreadNumber)
          {
              if (ThreadNumber == 1)
              {
                  this.button9.Text = text;
              }

              if (ThreadNumber == 2)
              {
                  this.button10.Text = text;
              }

              if (ThreadNumber == 3)
              {
                  this.button11.Text = text;
              }

              if (ThreadNumber == 4)
              {
                  this.button14.Text = text;
              }

              if (ThreadNumber == 5)
              {
                  this.button15.Text = text;
              }

              if (ThreadNumber == 6)
              {
                  this.button16.Text = text;
              }
              if (ThreadNumber == 7)
              {
                  this.button17.Text = text;
              }

              if (ThreadNumber == 8)
              {
                  this.button18.Text = text;
              }

              if (ThreadNumber == 9)
              {
                  this.button19.Text = text;
              }
          }
          


          private void EnterTextToPost(string text, int postNumber)
          {
              if (postNumber == 1)
              {
                  this.button1.Text = text;
              }

              if (postNumber == 2)
              {
                  this.button3.Text = text;
              }

              if (postNumber == 3)
              {
                  this.button4.Text = text;
              }

              if (postNumber == 4)
              {
                  this.button5.Text = text;
              }

              if (postNumber == 5)
              {
                  this.button6.Text = text;
              }

              if (postNumber == 6)
              {
                  this.button7.Text = text;
              }

              if (postNumber == 7)
              {
                  this.button8.Text = text;
              }

          }

        //************************* Register deal***************************************************
          public void CheckRegister(string name, string userName, string Email, string Password)
          {
             //RegisterResult(false);
          }

          public void RegisterResult(Boolean result)
          {
              RegisterForm.UpdateRegisterResult(result);
          }

        //******************************************************************************************



        //***************************Login**********************************************************//
          private void button23_Click(object sender, EventArgs e)
          {//login button
              LoginForm = new Form3(this);
              this.Hide();
              LoginForm.Show();
          }

          public void EnterLogin( string userName, string Password)
          {
              //RegisterResult(false);
          }

          public void RegisterLogin(Boolean result)
          {
              LoginForm.UpdateRegisterResult(result);
          }

     
        //******************************************************************************************


          //***************************Edit Post**********************************************************//
          private void button30_Click(object sender, EventArgs e)
          {
         
              MessageBox.Show("please choose a post to edit");
              this.EditOpen = true;

          }

          private void Start_Edit()
          {
              this.Hide();
              this.EditForm.Show();
          }

          public void Send_Edit_to_server(string text)
          {
              EnterTextToPost(text, this.pushed_now);
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }


          //******************************************************************************************

          //***************************Delete thread**********************************************************//

          private void button32_Click(object sender, EventArgs e)
          {//remove thread
              if (this.Is_Thread_screeen)
              {
                  MessageBox.Show("please choose the thread to delete");
                  DeleteThread = true;
              }
              else
              {
                  MessageBox.Show("Some Mistake happaned");
              }
              
            
          }


          public void Send_server_Del_thread(int place)
          {
              //here invoke the update or edit message ^^^^^^^^^^^^^^INVOKE MESSAGE^^^^^^ IMPLEMENT NEEDED
          }

          
          //**********************************************************************************************


          //***************************Delete subject**********************************************************//
          private void button26_Click(object sender, EventArgs e)
          {
              if (this.Is_Subject_screen)
              {
                  MessageBox.Show("please choose the Subject to delete");
                  DeleteSubject = true;
              }
              else
              {
                  MessageBox.Show("Some Mistake happaned");
              }

          }

          public void Send_server_Del_subject(int place)
          {
              //here invoke the update or edit message ^^^^^^^^^^^^^^INVOKE MESSAGE^^^^^^ IMPLEMENT NEEDED
          }
        
          //**********************************************************************************************


          //***************************Add thread**********************************************************//

          private void button31_Click(object sender, EventArgs e)
          {
              this.AddThreadForm = new Form6(this);
              this.AddThreadForm.Show();
          }

          public void Send_New_thread(string thread)
          {
            //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          //**********************************************************************************************

          //***************************Add Subject**********************************************************//

          private void button25_Click(object sender, EventArgs e)
          {
              this.AddSubjectForm = new Form7(this);
              this.AddSubjectForm.Show();
          }

          public void Send_New_subject(string thread)
          {
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          //**********************************************************************************************

          //***************************Threads Post Pushed**********************************************************//
          private void button9_Click(object sender, EventArgs e)
          { //first button
              this.pushed_now = 1;
              this.EditText = button9.Text;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button10_Click(object sender, EventArgs e)
          {//second button
              this.pushed_now = 2;
              this.EditText = button10.Text;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button11_Click(object sender, EventArgs e)
          {
              this.pushed_now = 3;
              this.EditText = button11.Text;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button14_Click(object sender, EventArgs e)
          {
              this.pushed_now = 4;
              this.EditText = button14.Text;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button15_Click(object sender, EventArgs e)
          {
              this.pushed_now = 5;
              this.EditText = button15.Text;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button16_Click(object sender, EventArgs e)
          {
              this.pushed_now = 6;
              this.EditText = button16.Text;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button17_Click(object sender, EventArgs e)
          {
              this.pushed_now = 7;
              this.EditText = button17.Text;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button18_Click(object sender, EventArgs e)
          {
              this.pushed_now = 8;
              this.EditText = button18.Text;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button19_Click(object sender, EventArgs e)
          {
              this.pushed_now = 9;
              if (this.DeleteThread == true)
              {
                  Send_server_Del_thread(pushed_now);
                  DeleteThread = false;
              }
              if (this.DeleteSubject == true)
              {
                  Send_server_Del_subject(pushed_now);
                  DeleteSubject = false;
              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }


          private void button1_Click(object sender, EventArgs e)
          {
              this.pushed_now = 1;
              this.EditText = button1.Text;
              if (EditOpen == true)
              {
                  this.EditForm = new Form5(this);
                  this.EditForm.UpdateTextToEdit(EditText);
                  
                  this.EditForm.Show();
                  this.EditOpen = false;

              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED

          }

          private void button3_Click(object sender, EventArgs e)
          {
              this.pushed_now = 2;
              this.EditText = button3.Text;
              if (EditOpen == true)
              {
                  this.EditForm = new Form5(this);
                  this.EditForm.UpdateTextToEdit(EditText);
                
                  this.EditForm.Show();
                  this.EditOpen = false;

              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button4_Click(object sender, EventArgs e)
          {
              this.pushed_now = 3;
              this.EditText = button4.Text;
              if (EditOpen == true)
              {
                  this.EditForm = new Form5(this);
                  this.EditForm.UpdateTextToEdit(EditText);
                
                  this.EditForm.Show();
                  this.EditOpen = false;

              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED

          }

          private void button5_Click(object sender, EventArgs e)
          {
              this.pushed_now = 4;
              this.EditText = button5.Text;
              if (EditOpen == true)
              {
                  this.EditForm = new Form5(this);
                  this.EditForm.UpdateTextToEdit(EditText);
                  
                  this.EditForm.Show();
                  this.EditOpen = false;

              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button6_Click(object sender, EventArgs e)
          {

              this.pushed_now = 5;
              this.EditText = button6.Text;
              if (EditOpen == true)
              {
                  this.EditForm = new Form5(this);
                  this.EditForm.UpdateTextToEdit(EditText);
               
                  this.EditForm.Show();
                  this.EditOpen = false;

              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button7_Click(object sender, EventArgs e)
          {
              this.pushed_now = 6;
              this.EditText = button7.Text;
              if (EditOpen == true)
              {
                  this.EditForm = new Form5(this);
                  this.EditForm.UpdateTextToEdit(EditText);
                
                  this.EditForm.Show();
                  this.EditOpen = false;

              }
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

          private void button8_Click(object sender, EventArgs e)
          {
              this.pushed_now =7;
              this.EditText = button8.Text;
              if (EditOpen == true)
              {
                  this.EditForm = new Form5(this);
                  this.EditForm.UpdateTextToEdit(EditText);
           
                  this.EditForm.Show();
                  this.EditOpen = false;

              }

          
              //here invoke the update or edit message ^^^^^^^^^^^^^^^^^^^^^^^^^^^ IMPLEMENT NEEDED
          }

      
    




    }
}
